Skip to content

[3주차] 이교형/[feat] 게시글 도메인 API 구현#128

Open
LGH0507 wants to merge 3 commits intoLeets-Official:이교형/mainfrom
LGH0507:이교형/3주차

Hidden character warning

The head ref may contain hidden characters: "\uc774\uad50\ud615/3\uc8fc\ucc28"
Open

[3주차] 이교형/[feat] 게시글 도메인 API 구현#128
LGH0507 wants to merge 3 commits intoLeets-Official:이교형/mainfrom
LGH0507:이교형/3주차

Conversation

@LGH0507
Copy link
Copy Markdown

@LGH0507 LGH0507 commented Apr 7, 2026

1. 과제 요구사항 중 구현한 내용

  • 게시글 CRUD(생성,조회,수정,삭제) 구현
  • api 명세서에 따른 공통 응답 구현
  • 전역 예외 처리 및 에러 코드 구현
  • 요청에 대한 처리를 성공한 경우 / 실패한 경우에 대한 결과 메시지

2. 핵심 변경 사항

  1. 게시글 CRUD 관련 Controller, Service, Dto 작성
  2. API 명세서에 따른 공통 응답 구조 및 전역 예외 처리 작성
  3. Swagger Test 위한 사용자 등록 로직 작성
  4. 페이징 적용

3. 실행 및 검증 결과

  • 실행 결과:
  • 게시글 등록 성공
image
  • 게시글 등록 실패
image
  • 게시글 조회(단건)
image
  • 게시글 조회(목록)
image
  • 게시글 수정
image
  • 게시글 삭제
image
  • 에러 로그
image

4. 완료 사항

  1. 게시글 생성, 수정, 삭제, 조회 구현
  2. 에러 코드 적용
  3. 공통 응답 적용
  4. 사용자 등록 로직 작성(Swagger Test)
  5. 페이징 적용

5. 추가 사항

  • 관련 이슈: closed #111

제출 체크리스트

  • PR 제목이 규칙에 맞다
  • base가 {이름}/main 브랜치다
  • compare가 {이름}/{숫자}주차 브랜치다
  • 프로젝트가 정상 실행된다
  • 본인을 Assignee로 지정했다
  • 파트 담당 Reviewer를 지정했다
  • 리뷰 피드백을 반영한 뒤 머지/PR close를 진행한다

@LGH0507 LGH0507 requested a review from a team April 7, 2026 19:16
@LGH0507 LGH0507 self-assigned this Apr 7, 2026
Copy link
Copy Markdown

@yeonjuncho yeonjuncho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 코드 깔끔하게 잘 작성해주신 것 같습니다. 고생하셨습니다

Comment on lines +93 to +110
// 공통 검증 로직
// 게시글 조회
private Post findPostOrThrow(Long postId) {
return postRepository.findById(postId)
.orElseThrow(() -> new GeneralException(ErrorCode.POST_NOT_FOUND));
}

// 사용자 조회
private User findUserOrThrow(Long userId) {
return userRepository.findById(userId)
.orElseThrow(() -> new GeneralException(ErrorCode.USER_NOT_FOUND));
}

private void validatePageRange(int page) {
if (page < MIN_PAGE || page > MAX_PAGE) {
throw new GeneralException(ErrorCode.POST_INVALID);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 게시글이 존재하는지, 사용자가 존재하는지에 대한 검증 코드를 매번 메소드마다 따로 작성했었는데, 이렇게 자주 사용하는 검증 코드를 메소드로 만들어두고 쓰면 가독성도 더 좋고 확장하기도 편할 것 같습니다. 고생 많으셨습니다!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

존재하지 않는 id인 경우에 커스텀 예외로 던지고, 전역 핸들러에서 처리하는 구조도 좋은 것 같습니다. 코드 참고해서 피드백 주신 부분 보완해보겠습니다!


private final UserService userService;

@Operation(summary = "유저 등록", description = "새로운 유저를 등록합니다.")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 API의 목적을 명확히 설명해 주셔서 협업하는 프론트엔드 개발자나 다른 팀원들이 이해하기 매우 좋을 것 같습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants